<template>
  <div class="venus-list-page">
    <!--签约查询界面-->
    <div class="page-search">
      <el-row type="flex" class="list-items">
        <div class="venus-input-box">
          <label>债券代码</label>
          <el-input v-model="table.bond_table.bond_code" class="venus-input-middle" placeholder="请输入债券名称" />
        </div>
        <div class="venus-input-box">
          <label>债券名称</label>
          <el-input v-model="table.bond_table.bond_name" class="venus-input-middle" placeholder="请输入债券名称" />
        </div>

        <div class="venus-input-box">
          <label>市场</label>
          <el-select v-model="table.bond_table.market_code" class="venus-input-middle" placeholder="--请选择--">
            <el-option v-for="(value,key,index) in dict.marketCode" :key="index" :label="value" :value="key" />
          </el-select>
        </div>
      </el-row>
      <div class="venus-input-box">
        <label>估值日期</label>
        <el-date-picker v-model="table.bond_table.start_date" type="date" class="venus-input-middle venus-input-date"
          value-format="yyyyMMdd" placeholder="请输入起始日期" />
        -
        <el-date-picker v-model="table.bond_table.end_date" type="date" class="venus-input-middle venus-input-date"
          value-format="yyyyMMdd" placeholder="请输入截止日期" />
      </div>

      <el-row>
        <div class="venus-btn-box" style="text-align: center;">
          <el-button type="success" @click="search">查询</el-button>
          <el-button type="info" plain @click="resetForm">重置</el-button>
          <el-button type="success" @click="addBean">新增</el-button>
        </div>
      </el-row>

    </div>
    <!--    查询列表返显-->
    <div class="page-list">
      <el-row type="flex" justify="space-between" class="page-list-head">
        <div class="title">查询结果</div>
      </el-row>
      <table-pagination :table-data="table.bond_table.tableData" :table-header-config="table.tableHeaderConfig"
        highlight-current-row :total="table.bond_table.total" :page-size="table.bond_table.limit" :now-page="table.bond_table.nowPage"
        :operation-config="table.operationConfig" @current-change="handleCurrentChange" />
    </div>
  </div>
</template>

<script>
  /* 自定义数据加载 */
  import request from '@/utils/request'
  import * as kk from '@/utils/k-utils'

  export default {
    name: 'BondInfo',
    data() {
      return {
        /* 数据字典*/
        dict: {
          marketCode: []
        },
        /* 表格*/
        table: {
          operationConfig: { // 表格操作配置
            fixed: 'left',
            width: 200,
            operationButton: [
              // 每一个操作。value:操作文字；func:回调函数
              {
                value: '修改',
                func: this.myModify
              },
              {
                value: '删除',
                func: this.myDelete
              }
            ]
          },
          tableHeaderConfig: [ // 表头配置
            {
              prop: 'bond_code',
              label: '债券代码'
            },
            {
              prop: 'bond_name',
              label: '债券名称'
            },
            {
              prop: 'tradedate',
              label: '估值日期'
            },
            {
              prop: 'market_code',
              label: '债券市场'
            },
            {
              prop: 'origin1',
              label: '数据来源'
            },
            {
              prop: 'b_anal_matu_cnbd',
              label: '得期偿(年)(元)'
            },
            {
              prop: 'b_anal_dirty_cnbd',
              label: '估值全价'
            },
            {
              prop: 'b_anal_accrint_cnbd',
              label: '应计利息(元)'
            },
            {
              prop: 'b_anal_net_cnbd',
              label: '估值净价(元)'
            },
            {
              prop: 'b_anal_yield_cnbd',
              label: '估值收益率(%)()元'
            },
            {
              prop: 'b_anal_modidura_cnbd',
              label: '估值修正久期(元)'
            },
            {
              prop: 'b_anal_cnvxty_cnbd',
              label: '估值凸性(元)'
            },
            {
              prop: 'b_anal_vobp_cnbd',
              label: '估值基点价值(元)'
            },
            {
              prop: 'b_anal_sprdura_cnbd',
              label: '估值利差久期(元)'
            },
            {
              prop: 'b_anal_sprcnxt_cnbd',
              label: '估值利差凸性(元)'
            },
            {
              prop: 'b_anal_price',
              label: '真实全价(元)'
            },
            {
              prop: 'b_anal_netprice',
              label: '真实净价(元)'
            },
            {
              prop: 'b_anal_yield',
              label: '真实收益率(%)(元)'
            },
            {
              prop: 'b_anal_modifiedduration',
              label: '真实修正久期(元)'
            },
            {
              prop: 'b_anal_convexity',
              label: '真实凸性(元)'
            },
            {
              prop: 'b_anal_bpvalue',
              label: '真实基点价值(元)'
            },
            {
              prop: 'b_anal_sduration',
              label: '真实利差久期(元)'
            },
            {
              prop: 'b_anal_scnvxty',
              label: '真实利差凸性(元)'
            },
            {
              prop: 'b_anal_credibility',
              label: '可信度'
            }

          ],
          bond_table: {
            limit: 10,
            total: 0,
            nowPage: 0,
            tableData: [], // 表格数据
            exeid: 'M8201EU013',
            //查询参数
            market_code: '',
            start_date: '',
            end_date: '',
            bond_code: '',
            bond_name: ''
          }
        }

      }
    },
    mounted() {
      // 初始化调用
      this.init()
    },
    methods: {
      init: function() {
        kk.k_load_dict(this, 'marketCode', 't8_market_code')
      },
      search() { // 查询函数
        this.table.bond_table.nowPage = 1
        kk.k_load_table(this, 'bond_table', 'bond')

      },
      myModify(item, index) {
        this.$router.push({
          path: '/update_bond_val',
          query: item
        })
      },
      myDelete(item, index) {
       this.$confirm('确认删除吗?', '提示', {})
         .then(() => {
          //删除数据
          kk.k_update_exeid('bond','M8201EU014', item).then(rep => {
            if (rep.success) {
              kk.k_load_table(this, 'bond_table', 'bond')
            }
          })
         })
         .catch(() => {  })

      },
      addBean() {
        this.$router.push({
          path: '/add_bond_val'
        })
      },
      resetForm() {
        this.table.bond_table.market_code = ''
        this.table.bond_table.start_date = ''
        this.table.bond_table.end_date = ''
        this.table.bond_table.bond_name = ''
        this.table.bond_table.bond_code = ''
      },
      handleCurrentChange(val) {
        this.table.bond_table.nowPage = val
        kk.k_load_table(this, 'bond_table', 'bond')
      }
    }
  }
</script>
<style scoped>
  /*让文本可以被选中*/
  .venus-list-page {
    -moz-user-select: text;
    /*火狐*/
    -webkit-user-select: text;
    /*webkit浏览器*/
    -ms-user-select: text;
    /*IE10*/
    -khtml-user-select: text;
    /*早期浏览器*/
    user-select: text;
  }
</style>
